This will inadvertently fix #337 as no lockfile will imply that all dependencies
are not precise, and will hence be fetched.
shell.set_verbose(options.flag_verbose);
let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path));
- ops::generate_lockfile(&root, shell, true)
+ ops::generate_lockfile(&root, shell)
.map(|_| None).map_err(|err| CliError::from_boxed(err, 101))
}
let source_id = SourceId::for_git(&url, reference.as_slice(), None);
- let mut config = try!(Config::new(shell, true, None, None).map_err(|e| {
+ let mut config = try!(Config::new(shell, None, None).map_err(|e| {
CliError::from_boxed(e, 1)
}));
let mut source = GitSource::new(&source_id, &mut config);
log!(4, "compile; manifest-path={}", manifest_path.display());
- if options.update {
+ if update {
return Err(human("The -u flag has been deprecated, please use the \
`cargo update` command instead"));
}
let lockfile = manifest_path.dir_path().join("Cargo.lock");
let source_id = package.get_package_id().get_source_id();
- let mut config = try!(Config::new(*shell, update, jobs, target.clone()));
+ let mut config = try!(Config::new(*shell, jobs, target.clone()));
let mut registry = PackageRegistry::new(&mut config);
match try!(ops::load_lockfile(&lockfile, source_id)) {
let ret = {
let _p = profile::start("compiling");
- let mut config = try!(Config::new(*shell, update, jobs, target));
+ let mut config = try!(Config::new(*shell, jobs, target));
try!(scrape_target_config(&mut config, &user_configs));
try!(ops::compile_targets(env.as_slice(), targets.as_slice(), &package,
use cargo_toml = util::toml;
pub fn generate_lockfile(manifest_path: &Path,
- shell: &mut MultiShell,
- update: bool)
+ shell: &mut MultiShell)
-> CargoResult<()> {
log!(4, "compile; manifest-path={}", manifest_path.display());
let source_ids = package.get_source_ids();
let resolve = {
- let mut config = try!(Config::new(shell, update, None, None));
+ let mut config = try!(Config::new(shell, None, None));
let mut registry = PackageRegistry::new(&mut config);
try!(registry.add_sources(source_ids));
None => return Err(human("A Cargo.lock must exist before it is updated"))
};
- let mut config = try!(Config::new(shell, true, None, None));
+ let mut config = try!(Config::new(shell, None, None));
let mut registry = PackageRegistry::new(&mut config);
let sources = match to_update {
fn update(&mut self) -> CargoResult<()> {
let actual_rev = self.remote.rev_for(&self.db_path,
self.reference.as_slice());
- let should_update = self.config.update_remotes() || actual_rev.is_err();
+ let should_update = actual_rev.is_err() ||
+ self.source_id.precise.is_none();
let (repo, actual_rev) = if should_update {
try!(self.config.shell().status("Updating",
pub struct Config<'a> {
home_path: Path,
- update_remotes: bool,
shell: &'a mut MultiShell,
jobs: uint,
target: Option<String>,
impl<'a> Config<'a> {
pub fn new<'a>(shell: &'a mut MultiShell,
- update_remotes: bool,
jobs: Option<uint>,
target: Option<String>) -> CargoResult<Config<'a>> {
if jobs == Some(0) {
human("Cargo couldn't find your home directory. \
This probably means that $HOME was not set.")
})),
- update_remotes: update_remotes,
shell: shell,
jobs: jobs.unwrap_or(os::num_cpus()),
target: target,
&mut *self.shell
}
- pub fn update_remotes(&mut self) -> bool {
- self.update_remotes
- }
-
pub fn jobs(&self) -> uint {
self.jobs
}
git_project.url())));
// Make sure we still only compile one version of the git repo
- assert_that(p.cargo_process("cargo-build"),
+ assert_that(p.process(cargo_dir().join("cargo-build")),
execs().with_stdout(format!("\
{compiling} bar v0.5.0 ({git}#[..])
{compiling} [..] v0.5.0 ({dir})
COMPILING, root))
.with_stderr(""));
})
+
+test!(two_deps_only_update_one {
+ let project = project("foo");
+ let git1 = git_repo("dep1", |project| {
+ project
+ .file("Cargo.toml", r#"
+ [package]
+ name = "dep1"
+ version = "0.5.0"
+ authors = ["carlhuda@example.com"]
+ "#)
+ .file("src/lib.rs", "")
+ }).assert();
+ let git2 = git_repo("dep2", |project| {
+ project
+ .file("Cargo.toml", r#"
+ [package]
+ name = "dep2"
+ version = "0.5.0"
+ authors = ["carlhuda@example.com"]
+ "#)
+ .file("src/lib.rs", "")
+ }).assert();
+
+ let project = project
+ .file("Cargo.toml", format!(r#"
+ [project]
+
+ name = "foo"
+ version = "0.5.0"
+ authors = ["wycats@example.com"]
+
+ [dependencies.dep1]
+ git = '{}'
+ [dependencies.dep2]
+ git = '{}'
+ "#, git1.url(), git2.url()))
+ .file("src/main.rs", "fn main() {}");
+
+ assert_that(project.cargo_process("cargo-build"),
+ execs()
+ .with_stdout(format!("{} git repository `[..]`\n\
+ {} git repository `[..]`\n\
+ {} [..] v0.5.0 ([..])\n\
+ {} [..] v0.5.0 ([..])\n\
+ {} foo v0.5.0 ({})\n",
+ UPDATING,
+ UPDATING,
+ COMPILING,
+ COMPILING,
+ COMPILING, project.url()))
+ .with_stderr(""));
+
+ File::create(&git1.root().join("src/lib.rs")).write_str(r#"
+ pub fn foo() {}
+ "#).assert();
+ git1.process("git").args(["add", "."]).exec_with_output().assert();
+ git1.process("git").args(["commit", "-m", "test"]).exec_with_output()
+ .assert();
+
+ assert_that(project.process(cargo_dir().join("cargo-update")).arg("dep1"),
+ execs()
+ .with_stdout(format!("{} git repository `{}`\n",
+ UPDATING, git1.url()))
+ .with_stderr(""));
+})